$(function(){


    function isAndroid() {
      var userAgent = navigator.userAgent || navigator.vendor || window.opera;

      if (/android/i.test(userAgent)) {
        return true;
      }
      return false;
    }
    
    var c={
        ajax:{
            allCount:'/account/mywallet-info',
            listCout:'/account/mywallet-detail-info',
        },
        data:{uid:XT.search.userId || 5320}    
    }

    var store=new Vuex.Store({
        state:{
            allCount:{} 
        },
        actions:{
           'get_allCount':function({commit,state},params){
                XT.jsonp({
                    url:c.ajax.allCount,
                    data:params.data,
                    success:function(data){
                      console.log(data)
                       commit('set_allCount',data) 
                    }
                })     
           },
           'get_revenue_list':function({commit,state},params){
                XT.jsonp({
                    url:c.ajax.listCout,
                    data:params.data,
                    success:function(res){
                       params.callback(res); 
                    }
                })
            }
        },
        mutations:{
            'set_allCount':function(state,data){
              console.log(data)       
               state.allCount=data
            }
        } 

    })

    var arr=[];
    var App=new Vue({
        el:'#app', 
        data:{
            colorIndex:'0',
            list:[]
        },
        store:store,
        methods:{
            'incomeType':function(index){
                this.colorIndex=index; 
                if(index==0){
                   
                }
            }
        },
        computed:{
            'allCount':function(){
              return this.$store.state.allCount;
            }
        },
        created:function(){
            this.$store.dispatch('get_revenue_list',{
                data:c.data,
                callback:function(res){  
                    $.each(res,function(){
                    var item=[
                        '<li>',
                            '<span class="item_name">'+this.incomeType+'</span>',
                            '<span class="item_yesDay item_reven">',
                                '<i class="zr_num">'+this.incomeYesterday+'</i>',
                                '<i class="zr_sy">昨日收益（魅力值）</i>',
                           '</span>',
                            '<span class="item_all item_reven">',
                                '<i class="all_num">'+this.incomeSum+'</i>',
                                '<i class="all_sy">总收益（魅力值）</i>',
                            '</span>',
                        '</li>'
                    ]
                    arr.push(item.join(''))
                    });
                    $('.list').html(arr.join(''))
                }
            });
            this.$store.dispatch('get_allCount',{
              data:c.data
            });
        }
    })

})